import java.util.Arrays;

public class Main {
    public static void isbubblesort(int[] arr){
        int n = arr.length;
        int dig=1;
        for(int i=0;i<n-1;i++){
            for(int j=0;j<n-i-1;j++){
                if(arr[j]>arr[j+1]){
                    dig=0;
                    int temp = arr[j];
                    arr[j] = arr[j+1];
                    arr[j+1] = temp;
                }
            }
            if(dig==1){
                break;
            }
        }
    }
    public static void main(String[] args) {
        int[] arr=new int[]{1,7,4,5,8,9,12,6};
        System.out.println("排序前："+(Arrays.toString(arr)));
        isbubblesort(arr);
        System.out.println("排序后"+(Arrays.toString(arr)));
    }
}
